<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 500px;
            height: 700px;
            /* background-color: aqua; */
            margin: 0 auto;

        }

        .num {
            /* width: 500px; */
            text-align: right;
        }

        textarea {
            width: 500px;
            height: 300px;
        }

        .active {
            text-align: right;
        }
    </style>
</head>

<body>
    <div class="box">
        <h2>提问</h2>
        <p class="num">0/49</p>
        <textarea name="" id="text" class="text"></textarea>
        <div class="active"><label for="niming">匿名</label><input type="radio" id="niming"><button>提交</button></div>
        <h2 class="pass">回答</h2>
        <p></p>

    </div>
    <script>
        let text = document.querySelector(".text")
        let btn = document.querySelector("button")
        let pass = document.querySelector(".pass")
        let num = document.querySelector(".num")



        btn.onclick = function () {
            console.log(text.value.length);
            if (text.value.length > 0) {
                let p = document.createElement("p")
                p.innerHTML = `正常:${text.value}`
                p.style.fontSize = "16px"
                pass.appendChild(p)
                text.value = ""
            }else{
                console.log("");
                
            }
        }
        btn.onkeydown = function(e){
            if(e.keyCode = 13){
                btn.onclick()
            }else{
                console.log("");
            }
        }
        // function nums(){
        //     let a = text.value
        //     num.innerHTML = `${a.length}/49`
        // }
        // btn.addEventListener("input",nums)
        







    </script>

</body>

</html>